<?php
require_once("config.php");

$username = "";
if (isset($_REQUEST["username"]))
{
	$username = $_REQUEST["username"];
}
$password = "";
if (isset($_REQUEST["password"]))
{
	$password = $_REQUEST["password"];
}

function login($username, $password){
	$sql = "select * from user where name='".$username."' and password='".$password."'";

	$db = mysql_query($sql) or die(mysql_error());
	$num = 0;

	while ($result = mysql_fetch_array($db))
	{
		$num ++;
	}
	if($num > 0)
		return 1;
	else
		return 0;
}
$data = "";
if($username != "" && login($username, $password) == 1){
	session_start();
	$_SESSION['username']=$username;
	$data = "true";
}
else{
	$data = "false";
}

echo json_encode( $data);


?>